#（1）导入绘图库
# 一切皆options
from pyecharts import options as opts
# 需要画什么就从charts里面调用
from pyecharts.charts import Line
# 主题
from pyecharts.globals import ThemeType


# （2）创建图表类对象，并设置图表初始化配置项
my_init_opts = opts.InitOpts(width='800px',height='500px',page_title='折线图',theme=ThemeType.SHINE)
line = Line(init_opts=my_init_opts)

# （3）添加数据，并设置图表系列配置项
x = ['周一','周二','周三','周四','周五','周六', '周日']
y1 = [820, 932,901,934, 1290, 1330,1320]
y2 = [550,432, 601,634,790, 830,820]
line.add_xaxis(xaxis_data=x)
line.add_yaxis(series_name='店铺1',y_axis=y1)
line.add_yaxis(series_name='店铺2',y_axis=y2,symbol='diamond',symbol_size=8,
               label_opts=opts.LabelOpts(color='blue'),
               linestyle_opts=opts.LineStyleOpts(is_show=True,width=3,type_='dashed',color='purple'))# 系列配置项

# 4.全局配置项：set_global_opts
line.set_global_opts(
    # 标题：titleopts
    title_opts=opts.TitleOpts(title='两个店铺的销售额',pos_left='center'),
    # 坐标轴
    xaxis_opts=opts.AxisOpts(name='日期',name_location='center',name_gap=45),
    yaxis_opts=opts.AxisOpts(name='销售额/万元',name_location='center',name_gap=35),
    # 图例
    legend_opts=opts.LegendOpts(pos_right='12%',pos_top='75%'),
    # 工具箱：toolboxopts
    toolbox_opts=opts.ToolboxOpts(is_show=True,pos_left='%80'),
    # 提示框：tooltipopts
    tooltip_opts=opts.TooltipOpts(is_show=True,trigger='axis',trigger_on='mousemove|click',axis_pointer_type='cross')
)

# 渲染图表
line.render('line1.html')
